import { BasicColumn, FormSchema } from '@/components/Table'

export const columns: BasicColumn[] = [
  {
    title: '组织编码',
    dataIndex: 'orgCode',
  },
  {
    title: '组织名称',
    dataIndex: 'orgName',
  },
  {
    title: '组织层级',
    dataIndex: 'orgLevel',
  },
  {
    title: '上级组织',
    dataIndex: 'parentOrgName',
  },
  // {
  //   title: '责任人',
  //   dataIndex: 'bossName',
  // },
  {
    title: '描述',
    dataIndex: 'description',
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: 'orgCode',
    label: '组织编码',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'orgName',
    label: '组织名称',
    component: 'Input',
    colProps: { span: 6 },
  },
]

export const formSchema: FormSchema[] = [
  {
    field: 'orgCode',
    label: '组织编码',
    component: 'Input',
    required: true,
  },
  {
    field: 'orgName',
    label: '组织名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'parentOrgId',
    label: '上级组织',
    component: 'TreeSelect',
    ifShow({ values }) {
      const { orgName, parentOrgId } = values
      return parentOrgId !== '-1'

      // Hide without a parentorg when editing
      // return parentorg || (!orgName && !parentorg)
    },
    componentProps: {
      fieldNames: {
        label: 'name',
        value: 'id',
      },
      getPopupContainer: () => document.body,
    },
    // required: true,
  },
  {
    field: 'orgLevel',
    label: '组织层级',
    component: 'InputNumber',
    required: true,
  },
  {
    label: '组织描述',
    field: 'description',
    component: 'InputTextArea',
  },
]

export const orgFormSchema: FormSchema[] = [
  {
    field: 'itemCode',
    label: '字典编码',
    component: 'Input',
    rules: [
      {
        required: true,
        message: '请输入字典编码',
      },
    ],
  },
  {
    field: 'itemName',
    label: '字典名称',
    component: 'Input',
    required: true,
  },
  {
    label: '描述',
    field: 'description',
    component: 'Input',
  },
]
